package com.neu.his.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neu.his.mapper.NonDrugDisturbMapper;
import com.neu.his.mapper.NonDrugMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;

@Data
public class NonDrugDisturb extends Base {
    private Long nonDrugId;
    private Long diagId;
    private int num;
    private BigDecimal totalCount;
    private boolean isPaid;
    private boolean haveDeliver;
    private String nonDrugResult;

    @TableField(exist = false)
    @Autowired
    NonDrugMapper nonDrugMapper;

    public void countTotal(){
        NonDrug nonDrug = nonDrugMapper.selectOne(new QueryWrapper<NonDrug>().eq("id", nonDrugId));
        totalCount = new BigDecimal(nonDrug.getNonDrugPrice().intValue() * num);
    }

    @TableField(exist = false)
    private DiagRecords diagRecords;

    @TableField(exist = false)
    private NonDrug nonDrug;

    @Override
    public String toString(){
        return JSON.toJSONString(this);
    }

}
